-
Notifications
You must be signed in to change notification settings - Fork 26
feat(artists): mark as favorite #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
src/hooks/useFavoriteState.ts
Outdated
| export function useFavoriteState(initialFavorites: string[]) { | ||
| const router = useRouter(); | ||
| const defaultValue = initialFavorites ? JSON.stringify(initialFavorites) : '[]'; | ||
| const [cookieValue, setCookieValue] = useCookie('relisten_favorites:artists', defaultValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a really hard time DRYing the relisten_favorites:artists variable to reuse in src/lib/serverFavoriteCookies.ts. It kept saying the export was a function?
Also open to changing naming convention. Figure it was worth scoping to artist so a different cookie name can be used for tracks.
src/lib/serverFavoriteCookies.ts
Outdated
| const cookieStore = await cookies(); | ||
|
|
||
| try { | ||
| const value = cookieStore.get('relisten_favorites:artists')?.value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you export the cookie key so its declared once and imported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. I added to src/lib/constants.ts b/c was getting some weird behavior importing/exporting between client and server components.
|
Is there any way we can make this work without calling router.refresh? |
|
Also might be better to use a Set here: |
Good call, just updated.
I can mess around with it for sure. I was doing router.refresh based on this comment in the original issue. |
|
yeah that's my bad, didn't think to realize it would also refetch the random shows. |
closes #77